using System;
using Science.Mathematics;
using L=Science.Physics.GeneralPhysics;
using M = Science.Mathematics.Calculus;

namespace Serway.Chapter42
{
	/// <summary>
	/// Example05: Probabilities for the Electron in Hydrogen
	/// Calculate the probability that the electron in the 
	/// ground state of hydrogen will be found outside the 
	/// first Bohr radius. 
	/// </summary>
	public class Example05
	{
		public Example05()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Hydrogen H = new L.Hydrogen();
			
			Function.DoubleToDouble f
				= new Function.DoubleToDouble(Prob);
			M.Integration1D obj = new M.Integration1D(f);
			obj.From = 0.0;
			obj.To = H.HydrogenRadiusNanoMeter;
			obj.Compute();

			result+=Convert.ToString(1.0 - obj.Result)+"\r\n";
		}
		private double Prob(double x)
		{
			L.Hydrogen H = new L.Hydrogen();
			Function.DoubleToDouble wavefunction
				= H.GroundStateWaveFunction;
			return 4.0*Math.PI*x*x*wavefunction(x)*wavefunction(x);

		}
	}
}
